!# WIBIOS 0.1
!# Copyright Matthew F. Rienzo, 2014

[HEADER]
  .bits 32
  .end
[VARS]
  *__##BIOS##__VERSION       "0.1"	
  *__##BIOS##__AUTHOR        "Matthew F. Rienzo"
  *__##BIOS##__PROC_ARCH     "WI100"
  *__##BIOS##__PROC_GEN      "WI10x"
  *NULL             0
  .end
[CODE]
  !# Copyright Matthew F. Rienzo, 2014
  
  ! int 0x10
  .__##BIOS##__print_to_cli:
    
    pop0x10 %a0
	
    _sl_
	  print STDOUT $regs->{a0};
    _end_
	
	free %a0
	
    ret
    .stop

  ! int 0x11
  
  .__##BIOS##__println_to_cli:
    pop0x11 %a0
    _sl_
      print STDOUT $regs->{a0}."\n";
    _end_
    free %a0
	ret
    .stop

  ! int 0x12
  .__##BIOS##__proc_info_arch:
    movv %s0 *__##BIOS##__PROC_ARCH
	
	push0x12 %s0
	
	ret
	.stop
	
  ! int 0x13
  .__##BIOS##__version:
    movv %s0 *__##BIOS##__VERSION
	
	push0x13 %s0
	
	ret
	.stop
	
  ! int 0x14
  .__##BIOS##__proc_gen:
    movv %s0 *__##BIOS##__PROC_GEN

    push0x14 %s0

    ret
    .stop
	
  ! int 0x15
  .__##BIOS##__setCursorPosition:
    ! in : x= a0, y = a1
	pop0x15 %a0
	pop0x15 %a1
	
	_sl_
	$__VM_HT->{__VM_Registry}->{__vmX} = $regs->{a0};
	$__VM_HT->{__VM_Registry}->{__vmY} = $regs->{a1};
	_end_
	
    free %a0
	free %a1
	ret
	.stop
	
  ! int 0x16
  .__##BIOS##__setColor:
    ! in : color=%a0
	pop0x16 %a0
	
	_sl_
	$__VM_HT->{__VM_Registry}->{__color} = $regs->{a0};
	_end_
	
	free %a0
	ret
	.stop
	
  ! int 0x17
  .__##BIOS##__setFontSize:
    ! in : size = a0
	pop0x17 %a0
	
	_sl_
	$__VM_HT->{__VM_Registry}->{__fonsize} = $regs->{a0};
	_end_
	
	free %a0
	ret
	.stop
	
  ! int 0x18
  .__##BIOS##__print:
    ! 80x25...
	! 800x600px screen...
	! 800/80 = 10.  So 10 px length
	! 600/25 = 24.  So 24px height
	pop0x18 %a0
	
	_sl_
	  my $msg = SDLx::Text->new(
	  x => $__VM_HT->{__VM_Registry}->{__vmX},
		  y => $__VM_HT->{__VM_Registry}->{__vmY},
		  color => $__VM_HT->{__VM_Registry}->{__color},
		  size => $__VM_HT->{__VM_Registry}->{__fontsize},
		  font => "FSEX300.TTF",
		);
		
		$msg->write_to($__VM_SDL_SCREEN, $regs->{a0});
		$__VM_SDL_SCREEN->update();
		
	  _end_
		
	  ret 
	  .stop
	 
  .IRQ_MAP:
    set __##BIOS##__print_to_cli                              0x10
	set __##BIOS##__println_to_cli                            0x11
	set __##BIOS##__proc_info_arch                            0x12
	set __##BIOS##__version                                   0x13
	set __##BIOS##__proc_gen                                  0x14
	set __##BIOS##__setCursorPosition                         0x15
	set __##BIOS##__setColor                                  0x16
	set __##BIOS##__setFontSize                               0x17
	set __##BIOS##__print                                     0x18
	
	.stop
	
  .__##BIOS##__main:
    loadi %a0 14
	
	push0x17 %a0
	int 0x17
	
	loadi %a0 0
	loadi %a1 0
	
	push0x15 %a0
	push0x15 %a1
	int 0x15
	
	loadd %a0 "0000000000000000000000000000000000000000000000000000000000000000000000000000000x"
	
	push0x18 %a0
	int 0x18
	
	_sl_
	  sleep(5);
	_end_
	
	int 0x00
	ret
	.stop

  .__entry:
    call main
	.stop
	
	!.__##BIOS##__planned_main:
		!# Draw a blue background
		!# and print message in middle
		
!		loadi %a0 36
!		call __##BIOS##__setFontSize
!!		
!		!# setCursorPos(30*8, 12*15)
!		loadi %a0 240
!		loadi %a1 180
!		call __##BIOS##__setCursorPosition
!		
!		loadd %a0 "WIBIOS version 1.0"
!		call __##BIOS##__print
!		
!		loadi %a0 14
!		call __##BIOS##__setFontSize
!		
!		loadi %a0 264
!		loadi %a1 225
!		call __##BIOS##__setCursorPosition
!		
!		loadd %a0 "Copyright (C) Matthew F. Rienzo, 2014"
!		call __##BIOS##__print
!		
!		loadi %a0 0
!		loadi %a1 570
!		call __##BIOS##__setCursorPosition
!		
!		loadd %a0 "Loading..."
!		call __##BIOS##__print
!		
!		free %a0
!		free %a1
!		
!		loadd %r9
!		
!		ret
!		.stop
!		
!		!# BIOS binaries don't need entry points, because the virtual machine just loads the functions, and if there's
!		!# a __##BIOS##__main it will execute that function, and then load the other binaries after __##BIOS##__main returns
!		
	.end